package com.ynunicom.dc.dingdingcontractapp.tasklistener;

import com.ynunicom.dc.dingdingcontractapp.utils.SpringHelper;
import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author: jinye.Bai
 * @date: 2020/6/5 17:30
 */
public class ContractSaverTaskListener implements TaskListener {
    private static final long serialVersionUID = 5303026947812088792L;


    @Override
    public void notify(DelegateTask delegateTask) {
        TaskService taskService = SpringHelper.getTaskService();
        Map<String,Object> map = taskService.getVariables(delegateTask.getId());
        String isContractSaverOk = (String) map.get("isContractSaverOk");
        if (Boolean.parseBoolean(isContractSaverOk)){
            taskService.complete(delegateTask.getId());
        }
    }
}
